package com.cy.pj.pool;

import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Scope("singleton")//用于指定类的实例作用域,不写@Scope默认就是单例(singleton)作用域
@Lazy
@Component
public class ObjectPool {//假设此对象为一个对象池
    public ObjectPool(){//假设运行项目启动类，此构造方法执行了，说明此类对象构建了。
        System.out.println("ObjectPool()");
    }

    @PostConstruct
    public void init(){
        System.out.println("init()");
    }

    @PreDestroy
    public void destory(){
        System.out.println("destory()");
    }
}
